<template>
  <div class="content-box">
    <nav-title title="招聘需求报批" :routerLink="routerLink" />
    <!-- 发起人基本信息 -->
    <div class="regulations-box">
      <div class="title">发起人基本信息</div>
      <v-base-info v-bind:baseInfo="allInfo"></v-base-info>
    </div>
    <!-- 详细信息 -->
    <div class="regulations-box">
      <div class="title">详细信息</div>
      <simple-line title="招聘负责人" v-bind:value="allInfo.cWfRecRes+' '+allInfo.cWfRecResName" />
      <!--   <div class="regulations-box">
        <folding title="申请表单填写" :is-add="false"> -->
      <div class="normal-info">
        <div class="regulations-box">
          <div class="title">职位情况</div>
          <simple-line title="需求部门" v-bind:value="allInfo.cXfrDeptDescr" />
          <simple-line title="需求人数" v-bind:value="allInfo.cRecPeonm" />
          <simple-line title="需求岗位" v-bind:value="allInfo.cRehJobcodeDesc" />
          <simple-line title="录用岗位职等" v-bind:value="allInfo.cDrftJoblvl" />
          <simple-line title="直接上级" v-bind:value="allInfo.cRecSupervisor+' '+allInfo.cRecSupervisorName" />
          <simple-line title="希望到岗时间" v-bind:value="allInfo.cRecRegDt" />
          <simple-line title="直接上级下属人数" v-bind:value="allInfo.cRecUnderling" />
          <simple-line title="工作经验" v-bind:value="allInfo.cRecExperience+'年'" />
        </div>
        <div class="regulations-box">
          <div class="title">编制情况</div>
          <simple-line title="招聘类别" v-bind:value="allInfo.cRecCatgoryValue" />
          <simple-line title="编制情况" v-bind:value="allInfo.cRecAuthValue" />
          <simple-line title="部门编制使用情况" v-bind:value="allInfo.cRecAuthDesc" />
          <simple-line title="招聘性质" v-bind:value="allInfo.cRecNatureValue" />
          <simple-line title="备注说明" v-bind:value="allInfo.cRecRemark" />
        </div>
        <div class="regulations-box">
          <div class="title">招聘要求</div>
          <simple-line title="学历" v-bind:value="allInfo.cRecEducationValue" />
          <simple-line title="专业" v-bind:value="allInfo.cRecMajor" />
          <simple-line title="工作职责" v-bind:value="allInfo.cWfRecLong3" />
          <simple-line title="任职资格" v-bind:value="allInfo.cWfRecLong1" />
          <simple-line title="经验要求" v-bind:value="allInfo.cWfRecLong2" />
          <simple-line title="其他" v-bind:value="allInfo.cRecOther" />
        </div>
      </div>
      <!-- </folding>
      </div> -->
    </div>

    <div class="regulations-box">
      <div class="title">流程信息</div>
      <file-line label="附件" :important="true" :fileitems="allInfo.wfFiles" :boldtitle="true" />
    </div>

    <div class="regulations-box">
      <div class="title">分权引用</div>
      <fqyy-line :editting="false" :fqyyFlag="fqyyInfo.cFqyyFlag" :noFqyySum="fqyyInfo.noFqyySum" :noFqyyRatio="fqyyInfo.noFqyyRatio"
        :fqyyMsg="fqyyInfo.cFqyyDetail" ref="fqyy"></fqyy-line>
    </div>

    <!-- 流程图 -->
    <div class="regulations-box">
      <div class="title">流程图</div>
      <v-flow-charts :transNum="cTransactionNbr"></v-flow-charts>
    </div>
    <!-- 审批意见 -->
    <div class="regulations-box" v-if="approved == '0'&&allInfo.cStepType!='C' && allInfo.cIsChuanyue != 'Y'">
      <div class="info-label">审批意见</div>
      <div class="info-label-text">
        <textarea v-if="approved == '0'" placeholder="请在这里输入..." rows="5" v-model="cComments"></textarea>
        <textarea v-else="" readonly rows="5" v-model="cComments"></textarea>
      </div>
    </div>

    <div style="height: 50px"></div>
    <!-- 底部按钮 -->
    <div v-if="approved == '0'">
      <operation-btn :cApprovalSw="allInfo.cApprovalSw" :cDenySw="allInfo.cDenySw" :cPushbackAllSw="allInfo.cPushbackAllSw"
        :cAddSw="allInfo.cAddSw" :cTransactionNbr="allInfo.cTransactionNbr" :cWfType="allInfo.cWfType" :cReadSw="allInfo.cIsChuanyue"
        :cStepType="allInfo.cStepType" :cComments="cComments" :approveBizType="'rec'" :getBizParams="getBizParams"></operation-btn>
      <!--  -->
    </div>
  </div>
</template>
<script>
  import { dateFormat } from "vux";
import fqyyLine from "../../components/basic/FqyyLine"
import Folding from './common/Folding'
import InforLine from '../../components/basic/InforLine'
import vBaseInfo from "../formalStaff/baseInfo";
import SimpleLine from '../../components/basic/SimpleLine'
import FileLine from '../../components/basic/FileLine'
import CommonUtil from '../../components/basic/util'
import { getRecruitmentNeedsInfo, getRecruitmentNeedsApproveRec,getFqyyInfo } from "../../api/api";
import operationBtn from "./common/operationBtn";
import vFlowCharts from "../formalStaff/common/flowChart";
import { json2Form } from "../../util/http";

export default {
  components: {
    operationBtn,
    dateFormat,
    vFlowCharts,
    SimpleLine,
    vBaseInfo,
    FileLine,
    fqyyLine,
    Folding,
    InforLine
  },

  created() {
    CommonUtil.tryLogin(this).then(()=>{
      this.cTransactionNbr = this.$route.query.cTransactionNbr;
      this.approved = this.$route.query.approved;
      this.loginOprid = this.$route.query.token;
      if (this.$route.query.approved == "1") {
        this.routerLink = "/todoList/done";
      } else {
        this.routerLink = "/todoList/todo";
      }
      this.getData();
    });
  },
  mounted() {},
  data() {
    return {
      fqyyInfo:{
        fqyyFlag:'',
        fqyyDetail:''
      },
      ynVal:[{ value: "是", key: "Y" }, { value: "否", key: "N" }],

      approved: '0',
      routerLink: "/todoList/todo",
      allInfo: {},
      cComments: "",
      displayVal: {},
      editVal: {},

    };
  },
  methods: {
    getData() {
      this.$vux.loading.show();
      getRecruitmentNeedsInfo({
        cTransactionNbr: this.cTransactionNbr,
        loginOprid: this.loginOprid
      })
        .then(res => {
          this.$vux.loading.hide();
          console.log(res);
          if (res && res.retCode === "000000") {

            CommonUtil.updateFileUrl(res.retData.wfFiles);
            // CommonUtil.fillNumberEmpty(res.retData,
            //   ["cPayAnnualSal", "cPayAplSal", "cPayDailySal", "cPayBonusNum", "age", "cIntershipTerm", "cMonthPayStd", "cPayFixedPct", "cPayFloatPct", "cSbPayBase"]
            // );
            // CommonUtil.fillYNShow(res.retData,
            //   ["cLaborAtriFlag", "cResignComFlag", "cRestricJobFlag", "cYn4", "cFloatSplitFlg", "cWxFlag", "cGjjFlag", "cBlacklistFlag"]
            // )

            // let auths = res.retData.authFileds;
            // for(var i=0;i<auths.length;i++) {
            //   this.displayVal[auths[i].fieldKey] = auths[i].isDisplay
            //   this.editVal[auths[i].fieldKey] = auths[i].isEdit
            // }
            this.allInfo = res.retData;
            this.allInfo.cWklifBgnDt2 = dateFormat(new Date(res.retData.cWklifBgnDt2), "YYYY/MM/DD");
            this.allInfo.birthdate = dateFormat(new Date(res.retData.birthdate), "YYYY/MM/DD");
            this.allInfo.cRecRegDt = dateFormat(new Date(res.retData.cRecRegDt), "YYYY/MM/DD");
            this.allInfo.cWklifBgnDt2 = dateFormat(new Date(res.retData.cWklifBgnDt2), "YYYY/MM/DD");
            this.allInfo.cWfAppDt = dateFormat(res.retData.cWfAppDt, "YYYY/MM/DD");

            getFqyyInfo({'cTransactionNbr':this.cTransactionNbr,'processType':'recruitment'}).then(res => {
                this.fqyyInfo = res.retData;
            })
          } else {
            this.$vux.alert.show({
              title: "提示",
              content: res.retMsg
            });
          }
        })
        .catch(res => {
          console.log("catch",res);
          this.$vux.loading.hide();
          this.$vux.alert.show({
            title: "警告",
            content: "网络异常，请稍后重试"
          });
        });
    },
    getBizParams(){
      var _this = this;
      var params = {};
      Object.keys(_this.editVal).forEach(function(key){
        if(key && _this.editVal[key]) {
          params[key] = _this.allInfo[key]
        }
      });
      return params;
    }
  }
};
</script>

<style type="text/scss" lang="scss">
  @import "../../styles/staff.scss";
@import "../../styles/rejectmain.scss";
</style>
